<template>
  <el-dialog
    title="拜访记录"
    :visible.sync="value"
    width="600px"
    :before-close="beforeClose"
  >
    <el-table :data="dataList">
      <el-table-column type="index" width="50"> </el-table-column>
      <el-table-column
        align="center"
        prop="visitTime"
        label="拜访时间"
        min-width="90"
      >
        <template slot-scope="{ row }">
          <span>{{ parseTime(row.visitTime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column
        align="center"
        prop="visitSubjectMatter"
        label="拜访事由"
        min-width="90"
      ></el-table-column>
      <el-table-column
        align="center"
        prop="visitRemark"
        label="备注"
      ></el-table-column>
    </el-table>
  </el-dialog>
</template>
<script>
import { listVisitRecord, manageListVisitRecord } from "@/api/visit";
export default {
  props: {
    value: {
      type: Boolean,
      default: false
    },
    row: {
      type: Object,
      default: () => null
    }
  },
  watch: {
    row(row) {
      if (row) {
				this.getList()
      }
    }
  },
  computed: {
    roles() {
      return this.$store.getters.roles;
    }
  },
  data() {
    return {
      dataList: [],
      pageNum: 1,
      pageSize: 10,
    }
  },
  methods: {
    getList() {
      let fn = listVisitRecord;
      if (this.roles[0].authority === "ROLE_ADMIN") {
        fn = manageListVisitRecord;
      }
			let params = {
				unitOrgCode: this.row.unitOrgCode
			}
      fn({
        ...params,
        pageNum: this.pageNum,
        pageSize: this.pageSize
      }).then(res => {
        this.dataList = res.data.list;
      });
    },
    beforeClose() {
      this.$emit('input', false)
    }
  }
}
</script>
<style lang="scss" scoped>

</style>